package calao.dba;

import java.util.Vector;

import calao.DesktopServiceImpl;
import calao.client.MissingPermissionException;
import calao.dba.client.DataAdminService;
import calao.storage.Storage;
import calao.storage.Table;

public class DataAdminServiceImpl
extends DesktopServiceImpl
implements DataAdminService
{

	public String[] listTables() 
	throws MissingPermissionException
	{
		Storage db = getWorkspace().getStorage();
		Vector<String> names = new Vector<String>();
		for (Table table : db.listTables()) {
			names.add(table.getName());
		}
		return names.toArray(new String[names.size()]);
	}

	public long countRows(String tableName) 
	throws MissingPermissionException 
	{
		Storage db = getWorkspace().getStorage();
		Table table = Table.getTable(tableName);
		return table!=null? db.countRecords(table) : -1;
	}

	public String[][] getTableRows(String table, int offset, int count) 
	throws MissingPermissionException 
	{
		// TODO retrieve table rows
		return null;
	}

}
